package com.sincon.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.sincon.common.annotation.Log;
import com.sincon.common.core.controller.BaseController;
import com.sincon.common.core.domain.AjaxResult;
import com.sincon.common.enums.BusinessType;
import com.sincon.system.domain.TbVideoCommand;
import com.sincon.system.service.ITbVideoCommandService;
import com.sincon.common.utils.poi.ExcelUtil;
import com.sincon.common.core.page.TableDataInfo;

/**
 * 视频关联指令Controller
 * 
 * @author LaoGao
 * @date 2024-12-23
 */
@RestController
@RequestMapping("/system/command")
public class TbVideoCommandController extends BaseController
{
    @Autowired
    private ITbVideoCommandService tbVideoCommandService;

    /**
     * 查询视频关联指令列表
     */
    @PreAuthorize("@ss.hasPermi('system:command:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbVideoCommand tbVideoCommand)
    {
        startPage();
        List<TbVideoCommand> list = tbVideoCommandService.selectTbVideoCommandList(tbVideoCommand);
        return getDataTable(list);
    }

    /**
     * 导出视频关联指令列表
     */
    @PreAuthorize("@ss.hasPermi('system:command:export')")
    @Log(title = "视频关联指令", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbVideoCommand tbVideoCommand)
    {
        List<TbVideoCommand> list = tbVideoCommandService.selectTbVideoCommandList(tbVideoCommand);
        ExcelUtil<TbVideoCommand> util = new ExcelUtil<TbVideoCommand>(TbVideoCommand.class);
        util.exportExcel(response, list, "视频关联指令数据");
    }

    /**
     * 获取视频关联指令详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:command:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tbVideoCommandService.selectTbVideoCommandById(id));
    }

    /**
     * 新增视频关联指令
     */
    @PreAuthorize("@ss.hasPermi('system:command:add')")
    @Log(title = "视频关联指令", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbVideoCommand tbVideoCommand)
    {
        return toAjax(tbVideoCommandService.insertTbVideoCommand(tbVideoCommand));
    }

    /**
     * 修改视频关联指令
     */
    @PreAuthorize("@ss.hasPermi('system:command:edit')")
    @Log(title = "视频关联指令", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbVideoCommand tbVideoCommand)
    {
        return toAjax(tbVideoCommandService.updateTbVideoCommand(tbVideoCommand));
    }

    /**
     * 删除视频关联指令
     */
    @PreAuthorize("@ss.hasPermi('system:command:remove')")
    @Log(title = "视频关联指令", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tbVideoCommandService.deleteTbVideoCommandByIds(ids));
    }
}
